<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->




    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="城市服务商"  style="margin-right: 10px">
              <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="广告商ID" style="margin-right: 10px">
              <a-input placeholder="请输入广告商ID" v-model="queryParam.id"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="广告商公司名称" style="margin-right: 10px">
              <a-input placeholder="请输入广告商公司名称" v-model="queryParam.companyName"></a-input>
            </a-form-item>
          </a-col>

<!--          <template v-if="toggleSearchStatus">-->
<!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--              <a-form-item label="二维码凭证">-->
<!--                <a-input placeholder="请输入二维码凭证" v-model="queryParam.ticket"></a-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--              <a-form-item label="二维码参数">-->
<!--                <a-input placeholder="请输入二维码参数" v-model="queryParam.qrParam"></a-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--              <a-form-item label="二维码图片">-->
<!--                <a-input placeholder="请输入二维码图片" v-model="queryParam.qrUrl"></a-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--          </template>-->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('广告商')">导出</a-button>
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"-->
<!--                @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel">-->
<!--            <a-icon type="delete" />-->
<!--            删除-->
<!--          </a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> 批量操作-->
<!--          <a-icon type="down" />-->
<!--        </a-button>-->
<!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">


<!--        <template slot="avatarUrl" slot-scope="text, record">-->
<!--          <div class="anty-img-wrap" style="height: 100px; width: 105px">-->
<!--            <j-image-upload v-if="record.avatarUrl" text="上传" disabled v-model="record.avatarUrl"></j-image-upload>-->
<!--          </div>-->
<!--        </template>-->




        <template slot="qrUrl" slot-scope="text, record">
          <div class="anty-img-wrap" style="height: 100px; width: 105px">
            <j-image-upload v-if="record.qrUrl" text="上传" disabled v-model="record.qrUrl"></j-image-upload>
          </div>
        </template>

        <span slot="action" slot-scope="text, record">
          <a  @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical" />
            <a @click="handlePromotion(record)">推广详情</a>
<!--          <a-divider type="vertical" />-->
<!--          <a-dropdown>-->
<!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!--            <a-menu slot="overlay">-->
<!--              <a-menu-item>-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
<!--            </a-menu>-->
<!--          </a-dropdown>-->
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <wydjAdvertiser-modal ref="modalForm" @ok="modalFormOk"></wydjAdvertiser-modal>
    <XhdjAdvertiserUserDetailModal ref="modalDetail" @ok="modalFormOk"></XhdjAdvertiserUserDetailModal>

  </a-card>
</template>



<script>
import '@/assets/less/TableExpand.less'
import WydjAdvertiserModal from './modules/WydjAdvertiserModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'
import XhdjAdvertiserUserDetailModal from './modules/XhdjAdvertiserUserDetailModal.vue'

export default {
  name: 'WydjAdvertiserList',
  mixins: [JeecgListMixin],
  components: {
    serveSelect,
    WydjAdvertiserModal,
    XhdjAdvertiserUserDetailModal
  },
  data() {
    return {
      description: '广告商管理页面',
      status: {
        0: '待审核',
        1: '已通过',
        2: '已拒绝'
      },
      options: [
        { label: '待审核', value: '0', color: 'orange' },
        { label: '已审核', value: '1', color: 'green' },
        { label: '已拒绝', value: '2', color: '#999' },
      ],
      // 表头
      columns: [
        // {
        //   width: 20,
        //   title: '广告商参数',
        //   align: 'center',
        //   dataIndex: 'userId'
        // },
        // {
        //   width: 60,
        //   title: '广告商用户头像',
        //   align: 'center',
        //   dataIndex: 'avatarUrl',
        //   scopedSlots: { customRender: 'avatarUrl' }
        // },

        // {
        //   width: 30,
        //   title: '审核状态',
        //   align: 'center',
        //   dataIndex: 'status',
        //   customRender: (text, record) => {
        //     switch (record.status) {
        //       case 0:
        //         return '待审核'
        //         break
        //       case 1:
        //         return '已审核'
        //         break
        //       case 2:
        //         return '已拒绝'
        //         break
        //     }
        //   }
        // },
        {
          title: '城市服务商',
          align: 'center',
          dataIndex: 'agencyName'
        },
        // {
        //   title: '城市服务商编码',
        //   align: 'center',
        //   dataIndex: 'agencyCode'
        // },
        {
          title: '广告商ID',
          align: 'center',
          dataIndex: 'id'
        },

        {
          title: '公司名称',
          align: 'center',
          dataIndex: 'companyName'
        },
        {
          title: '广告商姓名',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '广告商手机号',
          align: 'center',
          dataIndex: 'phone'
        },
        {
          title: '扫码已注册人数',
          align: 'center',
          dataIndex: 'regUserCount'
        },
        {
          title: '扫码未注册人数',
          align: 'center',
          dataIndex: 'notRegUserCount'
        },
        // {
        //   title: '二维码凭证',
        //   align: 'center',
        //   dataIndex: 'ticket'
        // },
        {
          title: '二维码参数',
          align: 'center',
          dataIndex: 'qrParam'
        },
        {
          width: 60,
          title: '二维码图片',
          align: 'center',
          dataIndex: 'qrUrl',
          scopedSlots: { customRender: 'qrUrl' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/sys/advertiser/wydjAdvertiser/list',
        delete: '/sys/advertiser/wydjAdvertiser/delete',
        deleteBatch: '/sys/advertiser/wydjAdvertiser/deleteBatch',
        exportXlsUrl: '/sys/advertiser/wydjAdvertiser/exportXls',
        importExcelUrl: '/sys/advertiser/wydjAdvertiser/importExcel'
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    handlePromotion(record) {
      this.$refs.modalDetail.edit(record.id)
      this.$refs.modalDetail.title = '推广详情'
      this.$refs.modalDetail.disableSubmit = false
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
</style>

